package com.hxd.otc.module.my.presenter;

import android.support.annotation.NonNull;

import com.hxd.otc.base.BaseBean;
import com.hxd.otc.common.enums.CountryCodeEnum;
import com.hxd.otc.module.my.bean.UploadImageBean;
import com.hxd.otc.module.my.contract.RealNameStep2Contract;
import com.hxd.otc.module.my.model.UserModel;
import com.hxd.otc.mvp.base.BasePresenter;
import com.hxd.otc.net.BaseObserver;

import java.util.HashMap;

public class RealNameStep2Presenter extends BasePresenter<RealNameStep2Contract.IView> implements RealNameStep2Contract.IPresenter {


    private final UserModel mUserModel;
    private HashMap<String, UploadImageBean> mRealNameImages;
    private CountryCodeEnum mRealNameType;

    public RealNameStep2Presenter(RealNameStep2Contract.IView iView) {
        super(iView);
        mUserModel = UserModel.getInstance();
    }

    public void setRealNameImages(HashMap<String, UploadImageBean> map) {
        mRealNameImages = map;
    }

    @Override
    public void realNameVerifyOfV1(String idCard, String age, int sex, String realName, String address) {


        mUserModel.realNameVerifyOfV1(idCard, age, sex, realName, address, mRealNameType, new BaseObserver<String>() {
            @Override
            public void onNext(@NonNull String msg, @NonNull String s) {
                mView.CommitRealNameInfoSuccess();
            }

            @Override
            public void onError(int errType, @NonNull String errMessage) {
                mView.showToast(errMessage);
            }
        }, mView.<BaseBean<String>>bindAutoDispose());
    }

    @Override
    public void setRealNameType(CountryCodeEnum realNameType) {
        mRealNameType = realNameType;
    }

    @Override
    public CountryCodeEnum getRealNameType() {
        return mRealNameType;
    }
}
